package com.bestcem.xm.om.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.ToString;

/**
 * @author zq.ding <zq.ding@idiaoyan.com>
 * @version v1.0
 * @date 2021/12/27 15:15
 */
@Getter
@ToString
public enum OmUserStatusEnum {
    /**
     * 启用
     */
    ENABLE("已启用", 0),

    /**
     * 禁用
     */
    DISABLE("已禁用", 1);

    private final String name;

    private final Integer index;

    OmUserStatusEnum(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public static String getNameByIndex(int index) {
        for (OmUserStatusEnum statusEnum : values()) {
            if (index == statusEnum.getIndex()) {
                return statusEnum.getName();
            }
        }
        return StrUtil.EMPTY;
    }

    public static Integer getIndexByName(String name) {
        for (OmUserStatusEnum statusEnum : values()) {
            if (name == statusEnum.getName()) {
                return statusEnum.getIndex();
            }
        }
        return null;
    }

}
